package com.miku.utils;

/**
 * 关于操作系统的工具
 * @author 杜金伟 [2016年4月8日 下午6:22:21]
 */
public class OSUtils {
	public static enum OSType{
		Unknown,
		Linux,
		Windows,
		Mac
	}
	
	public static String operatorSystemName = null;
	public static OSType osType = OSType.Unknown;
	
	public static String osName(){
		if(operatorSystemName != null) return operatorSystemName;
		
		operatorSystemName = System.getProperty("os.name").toLowerCase();
		if(operatorSystemName.indexOf("linux") >= 0) {
			operatorSystemName = "linux";
			osType = OSType.Linux;
		}
		else if(operatorSystemName.indexOf("windows") >= 0){
			operatorSystemName = "windows";
			osType = OSType.Windows;
		}
		else if(operatorSystemName.indexOf("mac") >= 0) {
			operatorSystemName = "mac";
			osType = OSType.Mac;
		}
		return operatorSystemName;
	}
	
	public static OSType osType(){
		if(operatorSystemName != null) return osType;
		osName();
		
		return osType;
	}
}